//
//  InvestItemTableViewCell.m
//  Kjs-iOS
//
//  Created by 江伟 on 16/7/6.
//  Copyright © 2016年 jmhz. All rights reserved.
//

#import "InvestItemTableViewCell.h"
#import "CommonUtil.h"

@implementation InvestItemTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.totalInvestmentLab.adjustsFontSizeToFitWidth = YES;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)setItem:(ItemInfo *)item
{
    NSLog(@"传进来了%@",item);
    self.itemNameLab.text = item.itemName;
    self.gdAnnualizedBenefitRateLab.text = [NSString stringWithFormat:@"%.2lf％",item.gdAnnualizedBenefitRate*100];
    self.interestDaysLab.text = [NSString stringWithFormat:@"%d天",item.interestDays];
    self.gdBenefitMode.text = [CommonUtil getGdBenefitModeStrWithMode:item.gdBenefitMode];
    
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    formatter.numberStyle = NSNumberFormatterDecimalStyle;
    NSString *totalInvestment = [formatter stringFromNumber:[NSNumber numberWithFloat:item.totalInvestment]];
    self.totalInvestmentLab.text = [NSString stringWithFormat:@"¥%@元",totalInvestment];
    //时间戳转换显示
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    [df setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"]];
    if (item.interestStartDate != -1 && item.interestStartDate != 0) {
        NSDate *interestStartDate = [NSDate dateWithTimeIntervalSince1970:item.interestStartDate/1000];
        self.interestStartDateLab.text = [df stringFromDate:interestStartDate];
    }else {
        self.interestStartDateLab.text = @"-";
    }
    switch (item.itemStatus) {
        case 7:
        {
            self.itemStatusLab.text = @"募集中";
        }
            break;
        case 9:
        {
            self.itemStatusLab.text = item.gdBenefitReturnStep;
        }
            break;
        case 10:
        {
            if ([item.investDelFlag isEqualToString:@"0"]){
                self.itemStatusLab.text = @"待退回";
            }else if ([item.investDelFlag isEqualToString:@"1"]){
                self.itemStatusLab.text = @"已退回";
            }
        }
            break;
        default:
            break;
    }
    
    
}
@end
